$(document).ready(function() {	
	$("#frmAdd").validate({
		errorClass		: 'errorMessage',
		errorElement	: 'span',
		onfocusout		: false,
		onkeyup			: false,
		rules: {
			pname:{
				required 			: true,
				minlength			: 2
			},
			pimage: {
				required			: true,
				validFormat			: true,
				validSize			: true
			}
		},
		messages: {			
			pname:{
				required 			: name_required,
				minlength			: name_minlength
			},
			pimage: {
				required			: image_required,
				validFormat			: image_format,
				validSize			: image_size
			}
		},
		errorPlacement: function(label, element) {			
			var id = element.attr('id');			
			label.insertAfter($('#' + id));			
		},
		submitHandler: function(form) {				
			form.submit();
		}
	});	
	$.validator.addMethod('validFormat',function(){
		var strImage = $('#pimage').val();
		return validateImage(strImage);
	});
	$.validator.addMethod('validSize',function(){
		return validateImgSize('pimage');
	});
});